package com.fu.plugin.navigation;

import com.fu.plugin.filter.FilterDemo;
import com.fu.plugin.item.MyItemPresentation;
import com.intellij.navigation.ItemPresentation;
import com.intellij.navigation.NavigationItem;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.Nullable;

public class MyNavigationItem implements NavigationItem {
    private PsiElement psiElement;
    private NavigationItem navigationItem;
    private String name;
    private FilterDemo demo;

    public MyNavigationItem(String name, PsiElement psiElement){
        this.psiElement = psiElement;
        if(psiElement instanceof PsiMethod){
            PsiMethod method = (PsiMethod)psiElement;
            this.name = method.getName();
        }

        if(psiElement instanceof NavigationItem){
            this.navigationItem = (NavigationItem)psiElement;
        }

        this.name = name;
        demo = new FilterDemo(name, name);
    }

    @Nullable
    @Override
    public String getName() {
        return name;
    }

    @Nullable
    @Override
    public ItemPresentation getPresentation() {
        return new MyItemPresentation(name);
    }

    @Override
    public void navigate(boolean b) {

    }

    @Override
    public boolean canNavigate() {
        return false;
    }

    @Override
    public boolean canNavigateToSource() {
        return false;
    }

    public String getValue(){
        return this.name;
    }

    public FilterDemo getDemo(){
        return demo;
    }
}
